package com.vector.demo.controller;


import com.vector.demo.pojo.Course;
import com.vector.demo.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 课程信息控制层
 */
@Controller
public class CourseController {

    @Autowired
    private CourseService courseService;

    /**
     * 查询课程信息控制器
     * @param model
     * @return
     */
    @RequestMapping("/selectCourseController")
    public String selectCourseController(Model model) {
        List<Course> list = courseService.selectCourse();
        model.addAttribute("list",list);
        return "selectGrade";
    }

    /**
     * 添加课程信息
     * @param course
     * @return
     */
    @RequestMapping("/addCourseController")
    public String addCourseController(Course course) {
        courseService.addCourse(course);
        return "selectGrade";
    }

    /**
     * 删除
     */
    @RequestMapping("/dropCourseController")
    public String dropCourseController(int cou_id) {
        courseService.dropCourseById(cou_id);
        return "selectGrade";
    }
    /**
     * 预更新
     */
    @RequestMapping("/preModifyCourseController")
    public String preModifyCourseController(int cou_id) {
        courseService.preModifyCourse(cou_id);
        return "selectGrade";
    }
    /**
     * 更新
     */
    @RequestMapping("/modifyCourseController")
    public String modifyCourseController(Course course) {
        courseService.modifyCourse(course);
        return null;
    }

}
